package com.xmall.sys.utils;


import com.xmall.define.dto.sys.DictDto;
import com.xmall.define.dto.sys.DictValueDto;
import com.xmall.define.request.sys.OperateLogRequest;
import com.xmall.sys.define.dto.dict.DictDo;
import com.xmall.sys.define.dto.operateLog.OperateLogDto;
import com.xmall.sys.define.request.dict.DictQueryParams;
import com.xmall.sys.define.dto.role.SysRoleDto;
import com.xmall.sys.define.dto.user.SysUserDto;
import com.xmall.sys.define.request.dict.DictListPageQueryRequest;
import com.xmall.sys.define.request.dict.DictUpdateRequest;
import com.xmall.sys.define.request.dict.DictValueUpdateRequest;
import com.xmall.sys.define.request.role.RoleUpdateRequest;
import com.xmall.sys.define.request.user.UserUpdateRequest;
import com.xmall.sys.entity.*;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

public interface ConvertUtils {

    /**
     * sys role
     */
    @Mapper(componentModel = "spring")
    interface RoleModule {
        RoleModule INSTANCE = Mappers.getMapper(RoleModule.class);

        Role toEntity(RoleUpdateRequest request);
        SysRoleDto toDto(Role role);
        List<SysRoleDto> toDtoList(List<Role> roleList);
    }

    /**
     * sys dict
     */
    @Mapper(componentModel = "spring")
    interface DictModule {
        DictModule INSTANCE = Mappers.getMapper(DictModule.class);

        Dict toEntity(DictUpdateRequest request);
        DictDto doToDto(DictDo dictDo);
        List<DictDto> toDtoList(List<DictDo> dictList);

        DictValue toValueEntity(DictValueUpdateRequest request);
        DictValueDto toValueDto(DictValue dictValue);
        List<DictValueDto> toValueDtoList(List<DictValue> dictValueList);

        DictQueryParams toQueryParams(DictListPageQueryRequest request);
    }

    /**
     * sys user
     */
    @Mapper(componentModel = "spring")
    interface UserModule {
        UserModule INSTANCE = Mappers.getMapper(UserModule.class);

        SysUserDto toDto(User user);
        User toEntity(UserUpdateRequest request);
    }

    /**
     * sys operate_log
     */
    @Mapper(componentModel = "spring")
    interface OperateLogModule {
        OperateLogModule INSTANCE = Mappers.getMapper(OperateLogModule.class);

        OperateLog toEntity(OperateLogRequest request);
        List<OperateLogDto> toDtoList(List<OperateLog> operateLogList);
    }

}
